package com.shop.dto.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author wzby
 * @Date: 2022/12/5 11:27
 */
public enum OrderPayStatus {
    COIN_PAY (1,"金币支付"),
    ALIPAY_PAY (2,"支付宝支付"),
    WECHAT_PAY (3,"微信支付"),
    UNION_PAY (4,"银联支付");

    OrderPayStatus(Integer code, String name){
        this.code = code;
        this.name = name;

    }
    private final  Integer code;
    private final  String name;
    public Integer getCode() {
        return code;
    }
    public String getName() {
        return name;
    }

    public static OrderPayStatus findByCode(Integer code){

        Optional<OrderPayStatus> first =  Arrays.stream(OrderPayStatus.values())
                .filter(p -> p.getCode().equals(code))
                .findFirst();
        return   first.orElse(null);


    }
}
